package net.zjitc.tree;

public class MyBinaryTree<E> implements BinaryTree<E> {
    private TreeNode<E> root;
    public MyBinaryTree(TreeNode<E> node){
        this.root = root;
    }
    public TreeNode<E> getRoot(){
        return root;
    }
    public void setRoot(TreeNode<E> root){
        this.root = root;
    }
    @Override
    public void creat(E var, TreeNode<E> left, TreeNode<E> right) {

    }

    @Override
    public TreeNode<E> getLChild(TreeNode<E> p) {
        return p.left;
    }

    @Override
    public TreeNode<E> getRChild(TreeNode<E> p) {
        return null;
    }

    @Override
    public void insertL(E var, TreeNode<E> p) {
        if (p.left != null){
            throw  new RuntimeException("左子树已存在");
        }
        TreeNode<E> node = new TreeNode<>(var);
        p.left = node;

    }
    @Override
    public void insertR(E var, TreeNode<E> p) {
        if (p.right != null){
            throw  new RuntimeException("右子树已存在");
        }
        TreeNode<E> node = new TreeNode<>(var);
        p.right = node;

    }
    @Override
    public void deleteL(TreeNode<E> p) {

    }

    @Override
    public TreeNode<E> search(TreeNode<E> root, E var) {
        return null;
    }

    @Override
    public void traverse(TreeNode<E> root, int i) {

    }

}
